window.onload = function () {
  new Vue({
    el: '#app',
    data: {
      url: "http://hd215.api.yesapi.cn/",
      tableData: [],
      perpage: 3,
      total: 0
    },
    mounted() {
      this.getDataList()
    },
    methods: {
      getDataList() {
        $.post(this.url,
          {
            app_key: "FF119DFB40E63EE8DFD7C74C8A9A4B8D",
            model_name: "movie",
            page: 2,
            perpage: this.perpage,
            s: "App.Table.FreeQuery",
            where: [["id", ">=", "1"]]
          }, (data, status) => {
            console.log(data);
            this.tableData = data.data.list
            this.total = data.data.total
          })
      },
      add() {
        this.perpage++
        console.log(this.perpage);
        console.log(this.total);
        if (this.perpage >= 0 && this.perpage < this.total) {
          this.getDataList()
        } else {
          this.perpage = this.total-1
          alert("不能再加啦！！！")
        }
      },
      sub() {
        this.perpage--
        console.log(this.perpage);
        if (this.perpage > 0) {
          this.getDataList()
        } else {
          this.perpage = 1
          alert("不能再减啦！！！")
        }

      }
    }
  })
};